package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * 商品目录品牌
 */
@Getter
@Setter
public class ProductBrand extends BaseDomain{

    //标题
    private String title;

    //封面
    private String coverUrl;

    //所属目录
    private ProductCatalog catalog;

    //状态
    private Integer state;

    public static final int STATE_AUDIT = 0;//默认
    public static final int STATE_RELEASE = 1;//热门
    public static final int STATE_REJECT = -1;//禁用

    //封装后台日报管理待审核网页需要的数据
    public String getStateName(){
        String stateName = "";
        switch (state){
            case 0:stateName = "默认"; break;
            case 1:stateName = "热门"; break;
            case -1:stateName = "禁用"; break;
        }
        return stateName;
    }

    //封装后台商城目录管理网页需要的数据
    public String getJson(){
        Map<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("coverUrl",coverUrl);
        if(catalog!=null){
            map.put("catalogId",catalog.getId());
            map.put("catalogTitle",catalog.getTitle());
        }
        map.put("state",state);
        return JSON.toJSONString(map);
    }
}